﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Silvermoon.Controls;
using System.Drawing;

namespace Passwords.Controls
{
    public class PasswordItemContextMenu : ContextMenu
    {
        private bool isFavesEnabled = true;

        public PasswordItemContextMenu()
            : base()
        {
            Items.Add(new MenuItem("Add to favorites", PasswordCommands.ChangeFave));
            Items.Add(new MenuItem("Delete", PasswordCommands.DeletePassword));
            Items.Add(new MenuItem("Edit", PasswordCommands.EditPassword));
            Width = 240;
        }

        public bool IsFavesEnabled
        {
            get { return isFavesEnabled; }
            set
            {
                if (IsFavesEnabled != value)
                {
                    isFavesEnabled = value;
                    MenuItem item = Items[0] as MenuItem;
                    Items.RemoveAt(0);
                    item.Dispose();
                    if (value)
                    {
                        item = new MenuItem("Add to favorites", PasswordCommands.ChangeFave);
                    }
                    else
                    {
                        item = new MenuItem("Remove from favorites", PasswordCommands.ChangeFave);
                    }
                    Items.Insert(0, item);

//                    Items[0].Enabled = value;
                }
            }
        }

    }
}

